package es.deusto.ingenieria.sd.tralala.client;

import java.net.MalformedURLException;
import java.rmi.NotBoundException;
import java.rmi.RMISecurityManager;
import java.rmi.RemoteException;

import es.deusto.ingenieria.sd.tralala.server.ITralalaManager;

public class ServiceLocator {
	private ITralalaManager ITralalaService;

	public ServiceLocator() {
		setService("//127.0.0.1:1099/TralalaServer");
	}

	public ITralalaManager getService() {
		return ITralalaService;

	}

	public void setService(String nombreDir) {

		try {
			if (System.getSecurityManager() == null) {
				System.setSecurityManager(new RMISecurityManager());
			}
			ITralalaService = (ITralalaManager) java.rmi.Naming
					.lookup(nombreDir);

		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (RemoteException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (NotBoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

}
